Grokking Scalable Systems for Interviews
Rate this course
Ask Author
Contribute
Back to course home

4% completed

Vote For New Content
Introduction
Course Overview
Who This Course Is for
Caching
What Is Negative Caching and When Should You Cache 404 or Empty Results?
What Is the Difference Between Soft TTL and Hard TTL, and Why Does It Matter?
How Can a Bloom Filter Reduce Cache or Database Load?
What Is Distributed Locking for Cache Rebuilds, and How Does It Prevent Cache Stampedes?
Load Balancing
What Are Sticky Sessions (Session Affinity) and When Should I Avoid Them?
What Is the Difference between Liveness Checks and Readiness Checks in Load Balancers?
What is Global Server Load Balancing (GSLB) and How GeoDNS and Anycast Work?
API Basics
What are the Main API Pagination Strategies (offset, cursor, keyset), and When Should I Use Each?
What are HTTP Conditional Requests (ETag, If‑None‑Match, Last‑Modified) and How They Reduce Load?
What Is the Difference between Rate Limiting and Throttling and Quotas?
What Are Idempotency Keys and How to Implement Them Safely for Payments
Databases
What are SQL Isolation Levels (Read Committed, Repeatable Read, Serializable), and What Anomalies Do They Prevent?
What Is a Write‑Ahead Log (WAL), and How Does It Ensure Durability?
What Is the Difference Between Synchronous and Asynchronous Replication, and When Should I Use Read Replicas?
What Is MVCC (Multi‑Version Concurrency Control), and How Does It Enable Concurrent Reads and Writes?
What Are Safe Patterns for Online Schema Changes vs. Offline Migrations?
Scalability
What is Little’s Law and How to Use It for Quick Capacity Estimates in System Design
How Can I do Back-of-the-Envelope Sizing for QPS, Bandwidth, Storage, and Peak vs. Average Load?
What are Cold Starts and Warm Starts, and Why Do They Matter for Performance?
Sharding and Partitioning
How Do I Choose a Good Shard Key and Avoid Hotspots (Bucketing and Key Randomization)?
What Are Range Sharding, Directory‑Based Sharding, and Geo‑Sharding, and What Are the Common Use Cases?
What Is the Difference Between Rendezvous Hashing and Consistent Hashing, and When Should I Use Each?
Messaging and Streaming
What Do At‑most‑once, At‑least‑once, And Exactly‑once Delivery Semantics Mean?
What Are Idempotent Producers And Consumers, And How Do De‑duplication Keys Work?
What Is Message Ordering, How Do Partition Keys Affect It, And When Can Ordering Break?
What Are Windowing And Watermarking In Streaming Systems, In Simple Terms?
Consistency and Replication
What Is Quorum (N, R, W), And Why Does R + W > N Give Strongly Consistent Reads?
What Are Common Conflict Resolution Strategies (Last‑write‑wins, Vector Clocks, Logical Clocks)?
What Are Read Repair, Hinted Handoff, And Anti‑entropy (Merkle Trees) In Eventually Consistent Systems?
What Is The Difference Between SLI, SLO, And SLA, And Can You Give Simple Examples?
What Is Opentelemetry, And How Do Traces, Spans, Metrics, And Logs Fit Together?
What Is An Error Budget, And How Should It Guide Release Decisions?
What Are The Trade‑offs Between Server‑stored Sessions And JWTs for Authentication?
What Is The Difference Between TLS And MTLS, And When Is MTLS Appropriate For Service‑to‑service Auth?
What Is Secrets Management, And How Do Environment Variables, KMS, And Vault Compare?
What Is A Replay Attack, And How Is It Different from Idempotency Issues?
What Are The Differences Between TCP, UDP, And QUIC, And When Should I Use Each?
What Is The Difference Between A Forward Proxy, A Reverse Proxy, And NAT?
What Changed From HTTP/1.1 To HTTP/2 To HTTP/3, And What Are Head‑of‑line Blocking And Multiplexing?
What Is the Difference Between Content‑Addressable Storage and Location‑Based Addressing?
What Are Checksums and Etags, and How Do MD5/SHA Compare to CRC for Integrity?
What Are Hot, Warm, Cold, and Archive Storage Tiers, and When Should I Use Each?
What Is the Outbox Pattern, and How Does Change Data Capture (CDC) Work at a High Level?
What Is CQRS (Command Query Responsibility Segregation), and When Should I Consider It?
What Are the Differences Between a Circuit Breaker, Retry With Backoff, and Rate Limiting?
What Are RPO and RTO, and How Do They Differ in Disaster Recovery Planning?
What Is the Difference Between Active‑Active and Active‑Passive Architectures?
What Is Graceful Degradation, and How Do Feature Flags Help Availability?
What Are the Differences Between UUID, ULID, KSUID, and Snowflake IDs, and How Do I Choose?
How Do Snowflake‑Style IDs Work (Timestamp, Worker, Sequence), and What Problems Do They Solve?
What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew Hard?
Final Words
Key Takeaways
What To Learn Next
What Is Quorum (N, R, W), And Why Does R + W > N Give Strongly Consistent Reads?

Quorum (N, R, W) is a mechanism in distributed databases where data is replicated to N nodes, and each read or write operation must get responses from at least R or W of those nodes respectively; requiring R + W > N guarantees that every read will include at least one up-to-date replica, thus providing strongly consistent results.

What Is Quorum in Distributed Systems?

In distributed systems, a quorum is the minimum number of nodes that must agree or respond for an operation (like a read or write) to be considered successful.

The term quorum originally comes from the non-technical context of meetings and voting. It means having enough members present to make a decision.

By analogy, in a cluster of database nodes, a quorum ensures enough replicas agree on a value so that the data is consistent.

Quorum (N, R, W) specifically refers to a tunable consistency model often used in NoSQL databases (for example, in Apache Cassandra or Dynamo-style databases). It involves three key parameters:

  • N (Replication Factor): the total number of replicas that store copies of the data. For example, if N = 3, there are three copies of each piece of data on three different nodes.

  • R (Read Quorum): the number of replica nodes that must respond to a read operation before the read is considered successful. This is sometimes called the read consistency level. A larger R means the read queries more nodes to verify the data (increasing consistency but also read latency).

  • W (Write Quorum): the number of replica nodes that must acknowledge a write operation for it to be considered successful. This is the write consistency level. A larger W means the system waits for more nodes to save the data (improving consistency but potentially adding write latency).

By choosing values for R and W (out of N total replicas), one can tune the consistency vs availability trade-off of the system.

For instance, requiring acknowledgments from all N replicas (i.e. W = N for writes or R = N for reads) gives the highest consistency but lowest availability, while requiring only one replica (R = 1 or W = 1) maximizes availability at the cost of potential stale data.

Quorum configurations allow a middle ground that can achieve strong consistency without always having to wait for every single replica.

Quorum Read Write
Quorum Read Write

Strong Consistency with R + W > N

In quorum consensus, strong consistency is guaranteed if the chosen R and W values satisfy the rule R + W > N.

This condition means that the sets of nodes involved in a write and a subsequent read must overlap.

At least one node that participated in the successful write will also be consulted during the read.

As a result, the read operation will always see the most recent write (or at least detect its presence), ensuring no stale (out-of-date) data is returned.

Why is overlapping important?

Imagine a distributed database with N replicas for each piece of data.

When a write occurs, it might not instantly reach all N nodes (due to asynchronous replication or some nodes being down).

However, if the write was confirmed by W nodes, those W nodes have the latest value.

Later, if a read query asks R nodes for the data, and R + W > N, mathematically, there is at least one node common between the write group and the read group.

That common node has the latest data, so the read operation can obtain the up-to-date value from it (or at least notice a newer timestamp/version). This overlap guarantees that the read will not unknowingly get only stale copies.

To put it another way, R + W > N ensures that a read quorum and a write quorum cannot be completely disjoint sets of nodes.

There’s always at least one replica that “witnessed” the most recent write and will respond to the read.

The system can then return the latest value (for example, by using timestamped writes and choosing the newest version) and even update any stale replicas in the process (a technique known as read repair in some databases).

Conversely, if R + W <= N, it’s possible for a read to happen entirely on nodes that did not get the latest write.

In that case, the read might return outdated data because its quorum of R nodes had no overlap with the W nodes that acknowledged the write.

The best such a system can guarantee is eventual consistency (the data will converge eventually, but a recent read may not see the most recent write).

This is why the rule R + W > N is critical for strong consistency. It forces overlap and eliminates the scenario of "dirty reads" or stale data being read without detection.

Example: Quorum in Action

To make this concrete, consider an example scenario with a replication factor of N = 3 (three replicas for each data item):

  • Strongly Consistent Setup: Suppose we set W = 2 and R = 2. This means any write must be confirmed by 2 out of the 3 nodes, and any read will query 2 out of 3 nodes. Here R + W = 2 + 2 = 4, which is > N (3), satisfying the quorum condition. If a client writes a new value, at least 2 nodes will have that value. A subsequent read will ask 2 nodes; even in the worst case, at least one of those 2 will be one of the nodes that has the latest value (because 2 + 2 > 3 guarantees overlap). Thus, the read will retrieve the latest value (and can update the stale replica if one of the two had old data). In fact, DataStax (Cassandra) documentation confirms that with N=3, using QUORUM for both reads and writes (which effectively means R=2, W=2) “will result in strong consistency.”. This configuration is often used when strong consistency is desired.

  • Eventually Consistent Setup: Now consider W = 1 and R = 1 for N = 3. A write will return success after only one node has the data, and a read will fetch from only one node. Here R + W = 1 + 1 = 2, which is <= N. In this case, a client could write a value (only one node has it), and immediately do a read from a different node that hasn’t received the update; that read would return the old value, i.e. stale data. There was no overlap between the one node written and the one node read. The system is only eventually consistent in this scenario: if no further writes happen, the other replicas will eventually get the update (through background synchronization), but a read right after the write might not be up-to-date. This is the trade-off when R+W is too low. You gain speed and availability, but risk consistency.

  • Balanced Quorum Setup: Many distributed databases offer a quorum or majority level (often called QUORUM in Cassandra) where R and W are chosen as a majority of N (roughly N/2 + 1). For example, with N = 3, a majority is 2 (since 3/2 + 1 = 2.5, rounded down to 2). So R = 2, W = 2 (as above) is a majority quorum. With N = 5, majority would be 3 (since 5/2 + 1 = 3.5, use 3). If N = 5, using R = 3 and W = 3 (both majorities) gives R + W = 6 > 5, ensuring strong consistency. In fact, a system with N=5 that writes to any 3 nodes and reads from any 3 nodes will always have at least one node in common that has the latest data. This configuration can tolerate up to 2 node failures while still maintaining consistency (since even with 2 down, 3 out of 5 can still respond). It’s a popular choice for balancing reliability and performance.

Why R + W > N Matters (Importance and Use Cases)

The quorum approach to consistency is important because it allows tunable consistency.

Systems like Apache Cassandra, Amazon DynamoDB, Riak, and others based on the Dynamo model let clients choose R and W per operation or per table.

This means developers can decide, for each query, whether they want it to be strongly consistent or if they can tolerate eventual consistency in exchange for lower latency or higher availability.

For instance, a finance application might use R+W > N for critical account updates (so that reads are always current), whereas a social media feed might use a lower consistency level to favor speed, accepting that some reads might be slightly stale.

From an interview preparation and learning standpoint, understanding quorum consensus (N, R, W) is valuable for grasping how distributed databases handle the CAP theorem trade-offs.

It demonstrates one way to achieve consistency (the "C" in CAP) even in systems that don’t have a single leader coordinating all writes.

By using quorums, the system can remain highly available (continue operating even if some nodes fail) and still keep data consistent as long as the quorum condition is met.

In practice, a quorum read/write system can tolerate up to N - (R or W) node failures without losing consistency.

For example, with majority quorums, the system can survive the failure of nearly half the replicas and still function correctly.

Some real-world notes on quorum usage:

  • In Apache Cassandra, consistency levels like ONE, QUORUM, and ALL correspond to different R and W values. The QUORUM level typically means R or W = ⌈N/2⌉ + 1 (majority). Cassandra’s documentation notes that if you “write at QUORUM and read at QUORUM”, you get strong consistency. If you drop below that (say, write at ONE and read at ONE), you only have eventual consistency. Cassandra even performs read repair in the background. If a quorum read finds a newer value on one node and stale values on others, it can update the stale ones to fix divergence.

  • In systems like Amazon DynamoDB or Riak, similar principles apply. They allow specifying R and W values for operations. The Dynamo white-paper popularized the notation (N, R, W) and this quorum approach for eventual consistency tunable to strong consistency by appropriate settings.

  • The concept of quorum isn’t limited to databases. It appears in distributed algorithms (like Raft or Paxos consensus) and even distributed locking. In those contexts, a quorum (often a majority) of nodes must agree on a value or grant a lock, to avoid split-brain decisions. The underlying principle is the same: requiring a certain threshold of agreement to ensure one group’s decision overlaps with any other group’s decision.

In summary, R + W > N is the magic formula for strongly consistent reads in a replicated data system.

It is crucial for ensuring that whenever you read data, you’re seeing the latest write.

This comes at the cost of potentially higher latency (because R and W are larger numbers, meaning waiting for more nodes to respond) or reduced availability (if enough nodes are down such that R or W cannot be met, the operation fails).

System designers choose these values based on application needs. For example, an e-commerce order system might favor consistency (R+W>N) to avoid showing incorrect stock levels, while a cached profile info service might allow R+W<=N to always return quickly even if slightly outdated.

What Are Windowing And Watermarking In Streaming Systems, In Simple Terms?
What Are Common Conflict Resolution Strategies (Last‑write‑wins, Vector Clocks, Logical Clocks)?
Mark as Completed

On this page

What Is Quorum in Distributed Systems?

Strong Consistency with R + W > N

Example: Quorum in Action

Why R + W > N Matters (Importance and Use Cases)